//index.js
//获取应用实例
const app = getApp();
// var template = require('../header/header.js');

Page({
    data: {},
    onLoad: function () {

    },
    onShow: function(){
        this.getUserInfo();
    },
    onHide: function () {
    },
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
        this.getUserInfo();
    },

    recharge: function(){
        app.navigateTo(app.page.Recharge);
    },

    /**
     * 获取用户信息
     */
    getUserInfo: function(){
        var _this = this;
        var object = {
            url: app.api.url.user.userInfo,
            success: function(res){
                if(res.status == 1) {
                    app.globalData.userInfo = res.data;
                    _this.setData({
                        userInfo: res.data
                    })

                } else {
                    app.showToast(res.info);
                }
            },
            complete: function() {
                wx.stopPullDownRefresh() //停止下拉刷新
            }
        }
        app.request(object);
    },
});
